<template>
  <a-button type="primary" @click="open">打开{{ demoValue }}</a-button>
</template>

<script setup lang="ts">
  import { ref } from 'vue'

  const demoValue = ref<number>(0)
  class Api {
    static instance = null
    static getInstance() {
      if (!Api.instance) {
        Api.instance = new Api()
        demoValue.value++
        console.log('%c [ 第一次？ ]-14', 'font-size:13px; background:#b3b70e; color:#f7fb52;')
      }
      return Api.instance
    }
  }

  const open = () => {
    const api = Api.getInstance()
    console.log('%c [ api ]-22', 'font-size:13px; background:#cda877; color:#ffecbb;', api)
  }
</script>

<style lang="less" scoped></style>
